<template>
    <div  >
       <div id="main3" class="Rose " ></div>
    </div>
</template>

<script>
import echarts from 'echarts'
export default {
  name: 'HomeRose',
  props: {
    subjectType: Object
  },
  data () {
    return {
    }
  },
  watch: {
    subjectType: {
      handler: function () {
        this.creatmap()
      },
      deep: true
    }
  },
  mounted () {
    this.creatmap()
  },
  methods: {
    creatmap () {
      var chartDom = document.getElementById('main3')
      var myChart = echarts.init(chartDom)
      var option3

      option3 = {
        title: {
          text: '南丁格尔玫瑰图',
          subtext: this.subjectType.title,
          left: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          left: 'center',
          top: 'bottom',
          data: ['rose1', 'rose2', 'rose3', 'rose4', 'rose5', 'rose6', 'rose7', 'rose8']
        },
        toolbox: {
          show: true,
          feature: {
            mark: {show: false},
            dataView: {show: false, readOnly: false},
            restore: {show: false},
            saveAsImage: {show: false}
          }
        },
        series: [
          {
            name: '专业类别',
            type: 'pie',
            radius: [20, 140],
            center: ['50%', '58%'],
            roseType: 'area',
            itemStyle: {
              borderRadius: 5
            },
            data: [
              {value: this.subjectType.PoliticsAndlaw, name: '政法'},
              {value: this.subjectType.Agriculture, name: '农业'},
              {value: this.subjectType.normalschool, name: '师范'},
              {value: this.subjectType.military, name: '军事'},
              {value: this.subjectType.Forestry, name: '林业'},
              {value: this.subjectType.Sports, name: '体育'},
              {value: this.subjectType.Art, name: '艺术'},
              {value: this.subjectType.comprehensive, name: '综合'},
              {value: this.subjectType.nation, name: '民族'},
              {value: this.subjectType.FinanceAndEconomics, name: '财经'},
              {value: this.subjectType.medicine, name: '医药'},
              {value: this.subjectType.EngineeringCourse, name: '工科'},
              {value: this.subjectType.language, name: '语言'},
              {value: this.subjectType.others, name: '其他'}
            ]
          }
        ]
      }

      myChart.setOption(option3)
      myChart.on('click', (params) => {
        this.$emit('getSchoolType', params.name)
      })
    }
  }

}
</script>

<style scoped>
.Rose{
    position: absolute;
    width: 490px;
    height: 340px;
    top:360px;
    align-content: center;
}

</style>>
